﻿

using System.Collections.Generic;
using System.Linq;
using WpfFeeCalculator.Properties;
using WpfFeeCalculator.Controllers;
using System.Threading.Tasks;

using System;
using System.Reactive.Linq;
using System.Reactive;
using WpfFeeCalculator.FeeWcfService;
namespace WpfFeeCalculator.Model
{
    public class FeeFacade : IFeeFacade
    {
        readonly FeeServiceClient server;
        public FeeFacade()
        {
            server = new FeeServiceClient();
        }

        public IObservable<System.Reactive.EventPattern<GetPortfoliosCompletedEventArgs>> GetPortfoliosAllAsync()
        {
            var observable = Observable.FromEventPattern<GetPortfoliosCompletedEventArgs>(h => server.GetPortfoliosCompleted += h, h => server.GetPortfoliosCompleted -= h);
            server.GetPortfoliosAsync();
            return observable;
        }

        public IObservable<System.Reactive.EventPattern<GetPriceCutOffsCompletedEventArgs>> GetPriceCutOffsForPortfolioAllAsync(int portfolioId)
        {
            var observable = Observable.FromEventPattern<GetPriceCutOffsCompletedEventArgs>(h => server.GetPriceCutOffsCompleted += h, h => server.GetPriceCutOffsCompleted -= h);
            server.GetPriceCutOffsAsync(Guid.NewGuid(), DateTime.Today);
            return observable;
        }


        public Task<List<PriceCutOff>> GetPriceCutOffsForPortfolio(int portfolioId)
        {
            return server.StaticGetPriceCutOff(Guid.Empty, DateTime.Today);
        }

        public Task<DataResult> GetPortfolioExcel(Portfolio portfolio, System.DateTime date, PriceCutOff priceCutOff)
        {

            var task = server.StaticGetPortfolioExcelAsync(portfolio, date, priceCutOff);
            return task;

        }

      


        

       
    }

}
